/**
 * Theme: Moltran Admin Template
 * Author: Coderthemes
 * Module/App: Dashboard
 */


!function ($) {
    "use strict";

    var Dashboard = function () {
        this.$body = $("body");
        this.$realData = []
    };


    //creates Pie Chart
    Dashboard.prototype.createPieGraph = function (selector, labels, datas, colors) {
        var data = [{
            label: labels[0],
            data: datas[0]
        }, {
            label: labels[1],
            data: datas[1]
        }, {
            label: labels[2],
            data: datas[2]
        }, {
            label: labels[3],
            data: datas[3]
        }];
        var options = {
            series: {
                pie: {
                    show: true
                }
            },
            legend: {
                show: false
            },
            grid: {
                hoverable: true,
                clickable: true
            },
            colors: colors,
            tooltip: true,
            tooltipOpts: {
                content: "%s, %p.0%"
            }
        };

        $.plot($(selector), data, options);
    },


        //initializing various charts and components
        Dashboard.prototype.init = function () {

            Morris.Line({
                element: 'website-stats',
                data: usersLoginList,
                xkey: 'y',
                ykeys: ['a', 'b'],
                stacked: false,
                labels: ['活跃', '新增'],
                lineColors: ['#29b6f6', '#6e8cd7'],
                fillColor: 'rgba(30, 136, 229, 0.3)',
                composite: true,
                highlightLineColor: 'rgba(0,0,0,.1)',
                highlightSpotColor: 'rgba(0,0,0,.2)',
            });
            var pielabels = ["穿山甲", "优量汇", "快手","其他"];
            var datas = [csjTotalRevenue, ylhTotalRevenue, ksTotalRevenue,otherTodayTotalRevenue];
            var colors = ["rgba(41,182,246,0.85)", "rgba(126,87,194,0.85)", "rgba(51,184,108,0.85)", "rgba(110,140,215,0.85)"];
            this.createPieGraph("#pie-chart #pie-chart-container", pielabels, datas, colors);

        },

        //init Dashboard
        $.Dashboard = new Dashboard, $.Dashboard.Constructor = Dashboard

}(window.jQuery),

//initializing Dashboard
    function ($) {
        "use strict";
        $.Dashboard.init()
    }(window.jQuery);
